from django.db import models
from django import forms

class CommDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)


class requestList(models.Model):
    location = models.CharField(max_length=250)
    date = models.CharField(max_length=200)
    disasterType = models.CharField(max_length=4)
    status = models.IntegerField()
    o_URL = models.CharField(max_length=200)
    requestunit = models.CharField(max_length=50)
    type = models.CharField(max_length=20)

class TrafficDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class WaterDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class OilDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class CommDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class GasDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class PowerDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class IrrigationDisaster(models.Model):
    Code=models.CharField(max_length=20)
    Date=models.CharField(max_length=32)
    Location=models.CharField(max_length=32)
    Type=models.CharField(max_length=32)
    Grade=models.IntegerField()
    Picture=models.CharField(max_length=200)
    Note=models.CharField(max_length=32)
    ReportingUnit=models.CharField(max_length=32)
    SequenceNumber = models.CharField(max_length=32)

class DeathStatistics(models.Model):
    code=models.CharField(max_length=20)
    location=models.CharField(max_length=32)
    date=models.CharField(max_length=32)
    number=models.IntegerField()
    reportingunit=models.CharField(max_length=32)

class InjuredStatistics(models.Model):
    code=models.CharField(max_length=20)
    location=models.CharField(max_length=32)
    date=models.CharField(max_length=32)
    number=models.IntegerField()
    reportingunit=models.CharField(max_length=32)

class MissingStatistics(models.Model):
    code=models.CharField(max_length=20)
    location=models.CharField(max_length=32)
    date=models.CharField(max_length=32)
    number=models.IntegerField()
    reportingunit=models.CharField(max_length=32)

class CivilStructure(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    basicallyintactsquare=models.IntegerField()
    damagedsquare=models.CharField(max_length=200)
    destroyedsquare = models.CharField(max_length=32)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)

class BrickwoodStructure(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    basicallyintactsquare=models.IntegerField()
    damagedsquare=models.CharField(max_length=200)
    destroyedsquare = models.CharField(max_length=32)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)

class MasonryStructure(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    basicallyintactsquare=models.IntegerField()
    slightdamagedsquare=models.CharField(max_length=200)
    moderatedamagedsquare = models.CharField(max_length=200)
    seriousdamagedsquare = models.CharField(max_length=200)
    destroyedsquare = models.CharField(max_length=32)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)

class FrameworkStructure(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    basicallyintactsquare=models.IntegerField()
    slightdamagedsquare=models.CharField(max_length=200)
    moderatedamagedsquare = models.CharField(max_length=200)
    seriousdamagedsquare = models.CharField(max_length=200)
    destroyedsquare = models.CharField(max_length=32)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)

class OtherStructure(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    basicallyintactsquare=models.IntegerField()
    slightdamagedsquare=models.CharField(max_length=200)
    moderatedamagedsquare = models.CharField(max_length=200)
    seriousdamagedsquare = models.CharField(max_length=200)
    destroyedsquare = models.CharField(max_length=32)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)

class CollapseRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class LandslideRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class DebrisRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class KarstRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class CrackRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class SettlementRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class OtherRecord(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    type=models.CharField(max_length=32)
    status=models.IntegerField()
    picture=models.CharField(max_length=200)
    note=models.CharField(max_length=32)
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class DisasterInfo(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    longitude=models.FloatField()
    latitude=models.FloatField()
    depth=models.FloatField()
    magnitude=models.FloatField()
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class DisasterPrediction(models.Model):
    code=models.CharField(max_length=20)
    date=models.CharField(max_length=32)
    location=models.CharField(max_length=32)
    longitude=models.FloatField()
    latitude=models.FloatField()
    depth=models.FloatField()
    magnitude=models.FloatField()
    reportingunit=models.CharField(max_length=32)
    sequencenumber = models.CharField(max_length=32)

class User(models.Model):
    '''用户表'''

    enumrole = (
        ('user', "普通用户"),
        ('manager', "管理员"),
    )

    name = models.CharField(max_length=128, unique=True)
    password = models.CharField(max_length=256)
    role = models.CharField(max_length=32, choices=enumrole, default='普通用户')

    def __str__(self):
        return self.name

    """class Meta:
        ordering = ['c_time']
        verbose_name = '用户'
        verbose_name_plural = '用户'"""

class UserForm(forms.Form):
    username = forms.CharField(label="用户名", max_length=128)
    password = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput)

class RegisterForm(forms.Form):
    enumrole =(
        ('user', "普通用户"),
        ('manager', "管理员"),
    )
    username = forms.CharField(label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control'}))
    password1 = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(label="确认密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    role = forms.ChoiceField(label='角色', choices=enumrole)
